package com.ruoyi.assets.queue.runner;

import com.ruoyi.assets.queue.service.MessageConsumer;
import com.ruoyi.common.constant.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MessageConsumerRunner implements CommandLineRunner {

    @Autowired
    private MessageConsumer messageConsumer;

    @Override
    public void run(String... args) {
        try {
            // 启动消费者，监听队列
            messageConsumer.consumeMessage(Constants.VISIT_QUEUE);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
}
